<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>16 复杂条件渲染</title>
</head>

<body>
    <div id="root"></div>
</body>

<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/prop-types@15.8.1/prop-types.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

<script type="text/babel">


    const getArticleItem = () => {
        const [articleType, setArticleType] = React.useState({ articleType: 1 })

        switch (articleType) {
            case 1:
                return <div>文章1</div>
            case 2:
                return <div>文章2</div>
            case 3:
                return <div>文章3</div>
            default:
                return <div>文章4</div>
        }
    }

    function App() {
        return (
            <div>
                {getArticleItem()}
            </div>
        )
    }

    const root = ReactDOM.createRoot(document.getElementById('root'))
    root.render(<App />)
</script>

</html>